package com.jjlin.chapter_5;

import java.util.*;

public class CD95{

    //	判断两个字符串是否为变形词
    public static boolean isDeformation(String str1, String str2){
        if(str1 == null || str2 == null || str1.length() != str2.length())
            return false;
        int[] map = new int[256];
        char[] chars1 = str1.toCharArray();
        char[] chars2 = str2.toCharArray();
        int n = chars1.length;
        for(int i = 0; i < n; i++)
            map[chars1[i]]++;
        for(int i = 0; i < n; i++){
            if(map[chars2[i]]-- == 0)
                return false;
        }
        return true;
    }

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        System.out.println(isDeformation(s1, s2));
    }
}
